package com.irisking.ikaisdk.netCommond;

import com.irisking.ikaisdk.AbstractServerSDK;
import com.irisking.ikaisdk.DeviceErrorCode;
import com.irisking.ikaisdk.dataStruct.BasicJsonRec;
import com.irisking.ikaisdk.dataStruct.BasicJsonResp;
import com.irisking.ikaisdk.dataStruct.CommandResp;
import com.irisking.ikaisdk.dataStruct.OpenDoorJsonRec;
import com.irisking.ikaisdk.handler.OperationCode;
import com.irisking.ikaisdk.netCommond.entity.*;

import java.util.Date;

public class NetCommand implements ICommand {


    private AbstractServerSDK abstractServerSDK;

    public NetCommand(AbstractServerSDK serverSDK){
        abstractServerSDK = serverSDK;
    }

    /**
     * 向客户端发送指令
     * @param sn
     * @param rec
     * @return
     */
    public CommandResp SendCommand(String sn , BasicJsonRec rec){
        BasicJsonResp resp = abstractServerSDK.SendCommandAndReadAck(sn, rec);
        CommandResp commResp = new CommandResp();
        if (resp == null)
        {
            commResp.setCode(DeviceErrorCode.ReqTimeOut);
            commResp.setMessage("请求超时");
        }
        else
        {
            commResp.setCode(resp.getCode());
            commResp.setMessage(resp.getMessage());
        }
        return commResp;
    }

    @Override
    public CommandResp OpenDoor(String sn, String cardID) {
        OpenDoorJsonRec rec = new OpenDoorJsonRec();
        rec.card_id = cardID;
        rec.setSn(sn);
        rec.setOperation(OperationCode.OpenDoor);
        CommandResp commandResp = SendCommand(sn,rec);
        return commandResp;
    }

    @Override
    public DeviceListResp GetDeviceList() {
        return null;
    }

    @Override
    public boolean IsConnected(String sn) {
        return false;
    }

    @Override
    public PersonListResp GetPersonList(String sn, int offset, int pageSize, Date startTime, Date endTime, boolean includeFeature) {
        return null;
    }

    @Override
    public PersonResp GetPerson(String sn, String personId, boolean includeFeature, boolean includeIrisImage, boolean includeFaceImage) {
        return null;
    }

    @Override
    public CommandResp AddPerson(String sn, PersonInfo personInfo, IrisFeature[] irisFeatures, IrisPic[] irisPics, FaceInfo[] faceInfo, String faceImage) {
        return null;
    }

    @Override
    public RegisterResp BatchAddPerson(String sn, PersonSuite[] personSuite) {
        return null;
    }

    @Override
    public CommandResp UpdatePerson(String sn, String personId, PersonInfo personInfo, String[] deleteFeatureIDs, IrisFeature[] irisFeatures, IrisPic[] irisPics, FaceInfo[] faceInfo, String faceImage) {
        return null;
    }

    @Override
    public DeletePersonResp DeletePerson(String sn, String[] personIds) {
        return null;
    }

    @Override
    public DeviceInfoResp GetDeviceInfo(String sn) {
        return null;
    }

    @Override
    public CommandResp SetDeviceTime(String sn, Date time) {
        return null;
    }

    @Override
    public CommandResp PowerOff(String sn) {
        return null;
    }

    @Override
    public CommandResp Reboot(String sn) {
        return null;
    }

    @Override
    public CommandResp ReSetDevice(String sn, String serverId, Date time, DeviceState deviceState) {
        return null;
    }

    @Override
    public CommandResp SetDeviceState(String sn, DeviceState deviceState) {
        return null;
    }

    @Override
    public DeviceStateResp GetDeviceState(String sn) {
        return null;
    }

    @Override
    public CommandResp VacuumEvent(String sn) {
        return null;
    }

    @Override
    public CommandResp VacuumSerivce(String sn) {
        return null;
    }

    @Override
    public CommandResp VacuumSerivceLog(String sn) {
        return null;
    }

    @Override
    public LogsResp GetLogs(String sn, int offset, int pageSize, Date startTime, Date endTime, int type) {
        return null;
    }

    @Override
    public CommandResp ConfigIpAddress(String sn, int configurationMode, String ipAddress, String subnetMask, String gateway, String serverIPAddress) {
        return null;
    }

    @Override
    public DeviceDoorResp GetDoorState(String sn) {
        return null;
    }

    @Override
    public CommandResp UpgradeFirmware(String sn, String version, String upgrade_url) {
        return null;
    }

    @Override
    public CommandResp SendCloudIdentifyResult(String sn, String cloud_send_sn, int recog_result, int device_identify_type, int identify_type, Date recogTime, PersonSuite[] personInfo) {
        return null;
    }

    @Override
    public CommandResp SendPasswordVerifyResult(String sn, String cloud_send_sn, int password_result, int surplus_result, Date recogTime, PersonInfo personInfo) {
        return null;
    }

    @Override
    public CommandResp StartCollectFeature(String sn, int featuretype, String collectid) {
        return null;
    }

    @Override
    public PermissionResp GetPermission(String sn, int persons_verify_flag) {
        return null;
    }

    @Override
    public CommandResp AddPermission(String sn, int count, Permission[] permission_list) {
        return null;
    }

    @Override
    public CommandResp UpdatePermission(String sn, int count, Permission[] permission_list) {
        return null;
    }

    @Override
    public CommandResp DeletePermission(String sn, int count, String[] permission_ids) {
        return null;
    }

    @Override
    public DeviceParamResp GetDeviceParam(String sn, String[] param) {
        return null;
    }

    @Override
    public CommandResp SetDeviceParam(String sn, DeviceParam[] param) {
        return null;
    }

}
